# ########## General Setup ##############

  target_link_libraries(ProSonic ${LIBS})

# ########## Resource compilation ########
IF(WIN32)
# Only Windows target needs resource compilation
# And MinGW is the only one that needs an explicit compile step
IF(MINGW)
IF(CMAKE_CROSSCOMPILING)
    ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DrawScreen_resource.obj
						  COMMAND i686-pc-mingw32-windres
							  -I${CMAKE_CURRENT_SOURCE_DIR}
							  -o ${CMAKE_CURRENT_BINARY_DIR}/DrawScreen_resource.obj
							  -i${CMAKE_CURRENT_SOURCE_DIR}/DrawScreen.rc
					      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/DrawScreen.rc
						  )
  ENDIF(CMAKE_CROSSCOMPILING)
  IF(NOT CMAKE_CROSSCOMPILING)
    ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DrawScreen_resource.obj
						  COMMAND windres
							  -I${CMAKE_CURRENT_SOURCE_DIR}
							  -o ${CMAKE_CURRENT_BINARY_DIR}/DrawScreen_resource.obj
							  -i${CMAKE_CURRENT_SOURCE_DIR}/DrawScreen.rc
					      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/DrawScreen.rc
						  )
  ENDIF(NOT CMAKE_CROSSCOMPILING)
ENDIF(MINGW)
ENDIF(WIN32)

# ########## Engine executable ##########
# Sources:
SET(Engine_executable_SRCS
    demo.c
    draw.c
    DrawScreen.rc
    m68k.c
    main.c
    menus.c
    obj01.c
    objects.c
    psg.c
    script.c
    script2.c
    sprites.c
    text.c
    tools.c
    ym2612.c
    zone.c
)

# Headers:
SET(Engine_executable_HDRS
    common.h
    draw.h
    error.h
    m68k.h
    menus.h
    mouse.h
    network.h
    obj01.h
    objects.h
    psg.h
    script.h
    sprites.h
    strings.h
    structs.h
    text.h
    tools.h
    ym2612.h
    zone.h
)

IF(WIN32)
SET(Engine_executable_HDRS
    ${Engine_executable_HDRS}
    DrawScreen_rc.h
)
ENDIF(WIN32)

# MSVC can natively handle Windows RC files
IF(MSVC)
SET(Engine_executable_SRCS
    ${Engine_executable_SRCS}
    DrawScreen.rc
)
ENDIF(MSVC)

# actual target:
IF(WIN32)
IF(MINGW)
ADD_EXECUTABLE(ProSonic ${Engine_executable_SRCS} DrawScreen_resource.obj)
ELSE(MINGW)
ADD_EXECUTABLE(ProSonic ${Engine_executable_SRCS})
ENDIF(MINGW)
ELSE(WIN32)
ADD_EXECUTABLE(ProSonic ${Engine_executable_SRCS})
ENDIF(WIN32)

# add install target:
INSTALL(TARGETS ProSonic DESTINATION bin)
